package com.feng.mybatis.controller;

import com.feng.mybatis.bean.Book;
import com.feng.mybatis.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BookController {
    @Autowired
    BookService bookService;

    @GetMapping("/getbook")
    @ResponseBody
    public Book getBook(@RequestParam("id") Integer id){
        Book bookById = bookService.getBookById(id);
        return bookById;
    }

    //http://localhost:8086/getCount
    //377
    @GetMapping("/getCount")
    @ResponseBody
    public Integer getCount(){
        Integer count = bookService.getCount();
        return count;
    }
}
